<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title></title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv=”X-UA-Compatible” content=”IE=edge,chrome=1″/>
    <link rel="stylesheet" type="text/css" href="../../css/defaultcss.css" />
    <link rel="stylesheet" type="text/css" href="../../css/amazeui.min.css" />
    <script type="text/javascript" src="../../js/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../../layer/layer.js"></script>
    <script type="text/javascript" src="../../js/index.js"></script>
    <script src='../../js/amazeui.min.js'></script>
    <script src='../../js/flex.js'></script>
    <link rel="stylesheet" href="../../css/weui.min.css">
    <link rel="stylesheet" href="../../css/css/stylesheets/index.css">

</head>

<body style='background:#fff'>
    <header>
        <div class="goBack">
            <img src="../../img/base/back.png" alt="返回">
        </div>
        <span class="title"> 青少年维权 </span>
    </header>
    <div class="content  consult_help answer_content">
        <ul class="tablist">
            <li>
                <a href="./consult_help.html">咨询求助</a>
            </li>
            <li class="active">
                <a href="javascript:void(0);">问题回复</a>
            </li>
            <li>
                <a href="./man_list.html">专家风采</a>
            </li>
            <li>
                <a href="./question.html">常见问题</a>
            </li>
        </ul>
        <ul class="answer_list" id="answer_list">
        </ul>
        <div class="loading" id="loading">
            <img src="../../img/loading.gif" alt="">
        </div>
        <div class='loadData' id="loadData">
            <span class='line line1'>
			</span>
            <span>
				已经到底啦~
			</span>
            <span class='line line2'>
			</span>
        </div>
    </div>

</body>

</html>

<script type="text/javascript ">
    $('.goBack').bind('click', function () {
        window.history.back()
    })
    var isLoading = true, //loading  ui
        messagePage = 1, //当前页面
        loadingState = true; //请求状态
    $('#loading').hide();
    $("#loadData").hide();
    var getData = function (pageNo) {
        if (isLoading && loadingState) {
            loadingState = false;
            HYIP.ajax({
                url: '/youth/counselList.action',
                type: 'get',
                data: {
                    pageSize: 10,
                    pageNo: pageNo
                }
            }, function (data) {
                loadingState = true;
                var list = data.data.list;
                var caseList = '';
                for (var i = 0; i < list.length; i++) {
                    var answer = list[i].answer;
                    if (list[i].answer == null) {
                        answer = '暂无回复'
                    }
                    caseList += '<li>                                                          ' +
                        '    <div class="time">                                        ' +
                        '        <span>                                                ' +
                        list[i].createTime +
                        '       </span>                                                ' +
                        '    </div>                                                    ' +
                        '    <div class="li_box">                                      ' +
                        '        <div class="title">                                   ' +
                        list[i].detail +
                        '        </div>                                                ' +
                        '        <div class="detail">                                  ' +
                        answer +
                        '        </div>                                                ' +
                        '    </div>                                                    ' +
                        '</li>                                                         '
                }
                $('#answer_list').append(caseList);
                if (data.data.hasNextPage) {
                    isLoading = true;
                    hasNextPage = true;
                    $('#loadData').hide();
                } else {
                    isLoading = false;
                    hasNextPage = false;
                    $('#loadData').show();
                    $("#loading").hide();
                }
            });
        }
    }
    getData(messagePage);
    $(window).scroll(function () {
        if (hasNextPage == true) {
            if (($("body").height() - $("body").scrollTop()) <= document.documentElement.clientHeight) {
                $("#loading").show();
                messagePage++;
                getData(messagePage);
            }
        }
    });
</script>